#include<stdio.h>
#include<string.h>
int main()
{
    int n = 0;
    while(~scanf("%d",&n))
    {
        for(int i = 0; i < n; i++)
        {
            char pwd[101] = {0};
            scanf("%s",pwd);
            int lower = 0,higher = 0,digit = 0,other = 0;
            if(pwd[0] >= '0' && pwd[0] <= '9')
            {
                printf("NO\n");
                continue;
            }
            if(strlen(pwd) < 8)
            {
                printf("NO\n");
                continue;
            }
            for(int i = 0; pwd[i] != '\0'; i++)
            {
                if(pwd[i] >= '0' && pwd[i] <= '9')
                    digit++;
                else if(pwd[i] >= 'a' && pwd[i] <= 'z')
                    lower++;
                else if(pwd[i] >= 'A' && pwd[i] <= 'Z')
                    higher++;
                else
                    other++;
            }
            if(other != 0)
            {
                printf("NO\n");
                continue;
            }
            if((lower > 0) + (higher > 0) + (digit > 0) < 2)
            {
                printf("NO\n");
                continue;
            }
            printf("YES\n");
        }
    }
    return 0;
}

